<%@ page import="com.jbit.examSystem.pojo.User" %>
<%@ page import="com.jbit.examSystem.pojo.Student" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>首页</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" href="images/favicon.ico">
    <link rel="stylesheet" href="/static/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/static/css/public.css" media="all"/>
    <link href="/static/css/bootstrap.min.css" rel="stylesheet"/>
    <%
        Integer classId = 0;
        User user = (User) session.getAttribute("user");
        if (user.getIdentityId() == 10000){
            Student student = (Student) user;
            classId = student.getClassId();
        }
    %>
</head>
<body class="childrenBody">
<blockquote class="layui-elem-quote layui-bg-green">
    <div id="nowTime"></div>
</blockquote>
<div class="layui-row layui-col-space10 panel_box">
    <input type="hidden" id="userName" value="${user.name}"/>
    <blockquote class="layui-elem-quote title">快捷菜单</blockquote>
    <div class="panel layui-col-xs12 layui-col-sm6 layui-col-md4 layui-col-lg2">
        <a href="javascript:;">
            <div class="panel_icon layui-bg-blue">
                <i class="layui-anim seraph icon-clock"></i>
            </div>
            <div class="panel_word">
                <span class="lastLoginTime">
                    <c:if test="${empty user.lastLoginTime}">
                        <fmt:formatDate value="${user.loginTime}"/>
                    </c:if>
                    <c:if test="${not empty user.lastLoginTime}">
                        <fmt:formatDate type="both" value="${user.lastLoginTime}"/>
                    </c:if>
                </span>
                <cite>上次登录时间</cite>
            </div>
        </a>
    </div>
</div>
<%--通知--%>
<c:choose>
    <c:when test="${user.identityId == 10000}">
        <blockquote class="layui-elem-quote main_btn">

            <div class="layui-timeline-title">
                <h3 class="layui-inline">通知</h3>
            </div>
        </blockquote>

        <%--            <div class="layui-table-tips" style="margin-left: 10px">--%>
        <%--                    ${user.email}--%>
        <%--            </div>--%>
        <table id="showExam" width="1000px">

        </table>
    </c:when>
    <c:when test="${user.identityId == 10001}">

    </c:when>
    <c:otherwise>

    </c:otherwise>
</c:choose>
<div class="layui-row layui-col-space12">
    <div class="layui-col-lg12layui-col-md12">

    </div>
</div>
<script type="text/javascript" src="/static/layui/layui.js"></script>
<script type="text/javascript" src="/static/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/js/main.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</body>
<script>
    $(function () {
        /*
        if (<%=classId%>){
            $.post(
                "exam/getExamByClassId",
                {"classId": "<%=classId%>"},
                function (data) {
                    var rows = data.rows;
                    if (data.code == 0){
                        for (var i = 0; i < data.total; i++){
                            var $tr = $("<tr class='examTr'></tr>");
                            $tr.append('<td width="30%" class="examTd">'+ rows[i].title + '</td>');
                            $tr.append('<td width="40%" class="examTd">'+ dateFormat(rows[i].examTime) + '</td>');
                            $tr.append('<td width="30%" class="examTd"><button>参加考试</button></td>');
                            $("#showExam").append($tr)
                        }
                    }
                }
            )
        }
        */
    })
    
    function dateFormat(date) {
        var date = new Date(date);
        var YY = date.getFullYear() + '-';
        var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
        var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
        var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
        var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
        var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
        return YY + MM + DD +" "+hh + mm + ss;
    }
</script>
</html>